<script setup>

</script>

<template>
  <div>
    <!-- 标题 -->
    <h4 class="text-center">请假列表</h4>
    <!-- 用户列表 -->
    <table class="table table-bordered table-striped table-hover">
      <thead>
      <tr>
        <th>工号</th>
        <th>姓名</th>
        <th>请假原因</th>
        <th>请假开始日期</th>
        <th>请假结束日期</th>
        <th>审批状态</th>

      </tr>
      </thead>
      <tbody>
      <tr v-for="(item,index)  in absentList" :key="item.id">
        <td>{{ item.e_ID }}</td>
        <td>{{ nowname[index] }}</td>
        <td>{{ item.a_REASON }}</td>
        <td>{{ item.a_STTIME }}</td>
        <td>{{ item.a_ENDTIME }}</td>
        <td>{{ item.a_RESPON}}</td>
      </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  name: 'MyAbsent',
  data() {
    return {
      absentList: [],
      nowname: []
    }
  },
  mounted() {
    this.getAbsentList();
  },
  methods:{
    getAbsentList(){
      let that=this;
      let department = localStorage.getItem('department');
      let myurl = '/api/gmanager/absentlist/'
      if(localStorage.getItem('job')==1)myurl = '/api/dmanager/absentlist/'+department;
      else if(localStorage.getItem('job')==0 || localStorage.getItem('job')==2)myurl = '/api/employee/absentlist/'+localStorage.getItem('token');
      console.log(myurl);
      axios.get(myurl).then(res =>{
        this.absentList= res.data.data;
        for(let i = 0;i < this.absentList.length;i++){
          axios.get('/api/personnel/' + res.data.data[i].e_ID).then(res2 =>{
            that.nowname.push(res2.data.data.e_NAME);
          })
        }
      })

    }
  }
}
</script>
<style scoped lang="less"></style>